n, m = map(int, input().split())
s = list(str(n))
l = len(s)
dp = [s.copy() for _ in range(l)]
for i in range(l):
    for _ in range(m):
        dp[i].pop(i-(m-1))
    dp[i] = dp[i][:l-m]
stack = list(map(lambda x: int("".join(x)), dp))
print(max(stack))